namespace ShapesLib
{
    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Text;

    /// <summary>
    /// Class to be able to draw circles.
    /// </summary>
    public class Circle : Shape
    {
        /// <summary>
        /// Radius of the circle.
        /// </summary>
        private int radius;
       
        /// <summary>
        /// Circle Point
        /// </summary>
        private Point point;

        #region constructor(s)

        /// <summary>
        /// Initializes a new instance of the <see cref="Circle"/> class.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <param name="radius">The radius.</param>
        public Circle(int x, int y, int radius)
        {
            X = x;
            Y = y;
            this.Radius = radius;

            FillColor = Color.Yellow; // Yellow is a static member of class Color
        }
       
        /// <summary>
        /// Initializes a new instance of the Circle class.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        public Circle(int x, int y)
        {
            this.point.X = x;
            this.point.Y = y;
            this.Radius = 5;
            this.FillColor = Color.Red;
        }
        #endregion

        /// <summary>
        /// Gets or sets the point.
        /// </summary>
        /// <value>
        /// The point.
        /// </value>
        public int PointX
        {
            get { return this.point.X; }
            set { this.point.X = value; }
        }

        /// <summary>
        /// Gets or sets the point.
        /// </summary>
        /// <value>
        /// The point.
        /// </value>
        public int PointY
        {
            get { return this.point.Y; }
            set { this.point.Y = value; }
        }

        /// <summary>
        /// Gets or sets the radius.
        /// </summary>
        /// <value>
        /// The radius.
        /// </value>
        public int Radius
        {
            get { return this.radius; }
            set { this.radius = value; }
        }

        #region Methods
        /// <summary>
        /// Draws the specified g.
        /// </summary>
        /// <param name="g">The g.</param>
        public override void Draw(Graphics g)
        {
            SolidBrush solidBrush = new SolidBrush(FillColor);
            g.FillEllipse(solidBrush, X - this.Radius, Y - this.Radius, 2 * this.Radius, 2 * this.Radius);

            Pen myPen = new Pen(PenColor, PenWidth);
            g.DrawEllipse(myPen, X - this.Radius, Y - this.Radius, 2 * this.Radius, 2 * this.Radius);
        }

        /// <summary>
        /// Draw2s the specified g.
        /// </summary>
        /// <param name="g">The Graphics g.</param>
        public void Draw2(Graphics g)
        {
            SolidBrush sbrush = new SolidBrush(FillColor);
            g.FillEllipse(sbrush, this.point.X - this.Radius, this.point.Y - this.Radius, 2 * this.Radius, 2 * this.Radius);

           // Pen myPen = new Pen(PenColor, PenWidth);

           // g.DrawEllipse(myPen, point.X - Radius, point.Y - Radius, 2 * Radius, 2 * Radius);
        }
       
        /// <summary>
        /// Scales the specified factor.
        /// </summary>
        /// <param name="factor">The factor.</param>
        public override void Scale(double factor)
        {
            this.Radius = (int)((double)this.Radius * factor);
        }

        /// <summary>
        /// Points the in shape.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <returns>If it's possible then it returns success, else false.</returns>
        public override bool PointInShape(int x, int y)
        {
            if ((double)(System.Math.Pow(x - X, 2) + System.Math.Pow(y - Y, 2)) < (double)this.Radius * this.Radius)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// Points the in circle.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <returns>true if x and y point in the circle ; flase otherwise</returns>
        public bool PointInCircle2(int x, int y)
        {
            if ((double)(System.Math.Pow(x - this.point.X, 2) + System.Math.Pow(y - this.point.Y, 2)) < (double)(this.Radius * this.Radius))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// Points the in circle.
        /// </summary>
        /// <param name="po">The point.</param>
        /// <returns> true if point in circle ; flase otherwise</returns>
        public bool PointInCircle2(Point po)
        {
            if ((double)(System.Math.Pow(po.X - this.point.X, 2) + System.Math.Pow(po.Y - this.point.Y, 2)) < (double)(this.Radius * this.Radius))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        #region Section3 method
        /// <summary>
        /// Draws for creation.
        /// </summary>
        /// <param name="g">The g.</param>
        public override void DrawForCreation(Graphics g)
        {
            SolidBrush solidBrush = new SolidBrush(Color.FromArgb(128, FillColor));
            g.FillEllipse(solidBrush, X - this.Radius, Y - this.Radius, 2 * this.Radius, 2 * this.Radius);

            Pen myPen = new Pen(PenColor, PenWidth);
            myPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            g.DrawEllipse(myPen, X - this.Radius, Y - this.Radius, 2 * this.Radius, 2 * this.Radius);
        }

        #endregion

        #endregion
    }
}
